<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>dom-practice</title>
    <style>
      * {
        margin: 0 auto;
        padding: 0;
      }
      h1 {
        font-weight: 300;
        font-size: 30px;
        text-align: center;
        margin-top: 10px;
      }
      input {
        margin-top: 0;
        margin-left: 15%;
        display: inline-block;
        color: darkgray;
        border: none;
        border-bottom: darkgray 1px solid;
        width: 70%;
        height: 30px;
      }
      .see {
        display: inline-block;
        margin-top: 10px;
        width: 30px;
        height: 30px;
        background: url("afternoon.png") no-repeat center;
        border: none;
      }
    </style>
  </head>

  <body>
    <h1 class="title">京东登录</h1>
    <div>
      <input type="text" value="用户名" title="username" />
    </div>
    <div>
      <input type="text" value="密码" title="password" class="password" />
      <button class="see"></button>
    </div>
    <script>
      var button = document.querySelector("button");
      var password = document.querySelector(".password");
      button.onclick = function () {
        button.style.background = "url('evening.png') no-repeat center";
        console.log(password.type);
        if (password.type == "password") password.type = "text";
        else password.type = "password";
      };
    </script>
  </body>
</html>
